package com.tangly.module.controller;

import com.tangly.common.base.BaseController;
import com.tangly.module.entity.LoanRateEntity;
import com.tangly.module.service.impl.LoanRateServiceImpl;
import com.tangly.module.vo.AppLoanRateVO;
import com.tangly.module.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


/**
import java.util.ArrayList;
import java.util.List;
 * created by yehao on 2018/7/27.
 */
@RestController
@RequestMapping("/app/system")
@Slf4j
@Api(value = "计算器利率")
public class AppLoanRateController extends BaseController {

    @Autowired
    private LoanRateServiceImpl loanRateService;

    @ApiOperation(value = "获取全部利率")
    @GetMapping("/rate")
    public ResultVO<AppLoanRateVO> getList(){
        List<LoanRateEntity> loanRateEntities=loanRateService.selectAll();
        List<AppLoanRateVO> list=new ArrayList<>();
        for (LoanRateEntity loanRateEntity:loanRateEntities){
            list.add(AppLoanRateVO.convert(loanRateEntity));
        }
        return new ResultVO<>(list);
    }
}
